#include <cstdio>
#include <cstring>

int max( int x, int y ) { return ( x > y ) ?x :y; }
int min( int x, int y ) { return ( x < y ) ?x :y; }
int f[ 1001 ][ 51 ];

int main( )
{
    int t, cas, n, m, i, j, k;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d%d%d", &cas, &m, &n);
        for ( i = 0; i <= n; i++ )
            f[ i ][ 0 ] = 0xfffffff;
        for ( i = 0; i <= m; i++ )
            f[ 0 ][ i ] = 0;
        for ( i = 1; i <= n; i++ )
            for ( j = 1; j <= m; j++ )
            {
                f[ i ][ j ] = 0xfffffff;
                for ( k = 1; k <= i; k++ )
                    f[ i ][ j ] = min( f[ i ][ j ], max( f[ k - 1 ][ j - 1 ], f[ i - k ][ j ] ) + 1 );
            }
        printf("%d %d\n", cas, f[ n ][ m ]);
    }
    return 0;
}